#ifndef _FMT_CVT_H_
#define _FMT_CVT_H_

extern "C" {
#include <libavutil/frame.h>
#include <libavutil/mem.h>
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include "libswresample/swresample.h"
#include "libswscale/swscale.h"
}

class FmtCvt
{
public:
    FmtCvt(uint64_t out_ch_layout = AV_CH_LAYOUT_MONO, enum AVSampleFormat out_format = AV_SAMPLE_FMT_S16, int out_sample_rate = 16000);
    ~FmtCvt();

    int init(AVFrame *frame);
    int convert(AVFrame *frame, uint8_t** out_buffer_pptr);
    int flush(uint8_t** out_buffer_pptr);
    int exit();

private:
    SwrContext *m_swr_ctx;
    uint64_t m_out_layout;
    enum AVSampleFormat m_out_format;
    int m_out_sample_rate;
    uint8_t *m_out_buffer;
    int m_malloc_size;
    //std::string mTipTxt;
};

#endif
